import com.yenchingcheng.entity.CareTaker;
import com.yenchingcheng.entity.Originator;

/**
 * @Author Yenchingcheng
 * @Date 2024/1/18 14:36
 * @Description 测试类
 **/
public class Test {

    public static void main(String[] args) {
        Originator originator = new Originator();
        CareTaker careTaker = new CareTaker();
        originator.setState("State #1");
        originator.setState("State #2");
        careTaker.add(originator.saveStateToMemento());
        originator.setState("State #3");
        careTaker.add(originator.saveStateToMemento());
        originator.setState("State #4");

        System.out.println("Current State:" +originator.getState());
        Originator firstSave = new Originator();
        firstSave.getStateFromMemento(careTaker.getMemento(0));
        System.out.println("First State:" +firstSave.getState());
        Originator secondSave = new Originator();
        secondSave.getStateFromMemento(careTaker.getMemento(1));
        System.out.println("Second State:" +secondSave.getState());
    }
}
